#include "posix_pipe.h"
#include <unistd.h>
#include <cstring>
#include <cerrno>

namespace wilson::sys
{
    posix_pipe::posix_pipe()
    {
        int fds[2]{};
        if (::pipe(fds) == -1) [[unlikely]]
        {
            throw ::std::runtime_error{ ::strerror(errno) };
        }
        pp_read  = fd_guard{ fds[0] };
        pp_write = fd_guard{ fds[1] };
    }
}
